const app = getApp();
var config = app.globalData.config;
const http = require('../../utils/http.js');

Page({
  data: {
    curriculum_id:0,
    schoolName:"",  //学校名称
    semesterName:"",  //学期名称
    className:"", //班级名称
    enrollNum:0,  //报名人数
    registeredNum:0, //已报名人数
    studentList:[],  //报名人
    studentname:""  //学生名称-搜索条件
  },
  onLoad(options) {
    this.data.curriculum_id = options.curriculum_id;
    this.getCurriculumDetail();
  },
  getCurriculumDetail(){
    var that = this;
		http.httpPost(config.getCurriculumDetail, {
      curriculum_id: that.data.curriculum_id,
      studentname:that.data.studentname
		}, function(e) {
			if (e.code == 1) {
				var schoolName = e.data.schoolName;
				var semesterName = e.data.semesterName;
				var className = e.data.className;
				var enrollNum = e.data.enrollNum;
				var registeredNum = e.data.registeredNum;
				var studentList = e.data.studentList;
        
        that.setData({
          schoolName: schoolName,
          semesterName: semesterName,
          className: className,
          enrollNum: enrollNum,
          registeredNum: registeredNum,
          studentList: studentList
        });

        if(studentList.length==0){
          wx.showToast({
            icon:'none',
            title: '暂无数据',
          })

        }

			}
		});
  },
  searchFun(e) {//搜索
    var searchName = e.detail.value;
    console.log(searchName);
		this.setData({
			studentname: searchName
    });
    console.log(this.data.curriculum_name);
		this.getCurriculumDetail();
  },
  onReady() {

  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})